//
//  ChangePwdByPhoneQueryController.m
//  DYLYJ
//
//  Created by JM on 15/11/23.
//  Copyright © 2015年 JM. All rights reserved.
//

#import "ChangePwdByPhoneQueryController.h"
#import "DYRequestAll.h"
#import "DYUIKit.h"
@interface ChangePwdByPhoneQueryController ()
@property(nonatomic,strong)IBOutlet UITextField *pwdTextFeild;
@property(nonatomic,strong)IBOutlet UITextField *pwdQueryTextFeild;
@end

@implementation ChangePwdByPhoneQueryController

- (void)viewDidLoad {
    [super viewDidLoad];
    
   
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)clickFinishBtn{
    [self.view endEditing:YES];
    if (self.pwdTextFeild.text.length == 0){
        [MJAlertView showMessage:@"请输入密码"];
        return;
    }
    if (self.pwdQueryTextFeild.text.length == 0){
        [MJAlertView showMessage:@"请输入确认密码"];
        return;
    }
    
    if (![self.pwdTextFeild.text isEqualToString:self.pwdQueryTextFeild.text]){
        [MJAlertView showMessage:@"密码不一致"];
        return;
    }
    ChangePwdByPhoneRequest *request = [ChangePwdByPhoneRequest request];
    request.DY_phone = self.phone;
    request.DY_code = self.code;
    request.DY_newPassword = self.pwdTextFeild.text;
    [request requstWithCompletionHandler:^(DYResponse *rs, NSError *error) {
        if (error){
            [MJAlertView showMessage:error.localizedDescription];
            return ;
        }
        [MJAlertView showAlertViewWithTitle:@"提示" message:@"修改成功成功" clickedButtonBlock:^(NSInteger index) {
            [self.navigationController popToRootViewControllerAnimated:YES];
        } cancelButtonTitle:@"确定" otherButtonTitles:nil];
        
    }];
}
@end
